// 二叉树最近祖先
var lowestCommonAncestor = function(root, p, q) {
    if((root.val-p.val)*(root.val-q.val)<0) {
       return root
    }
    if (p.val==root.val){
            return p;
        } 
        if (q.val==root.val){
            return q;
        }
    if((root.val-p.val)*(root.val-q.val)>0) {
        if(root.val<q.val && root.val<p.val) 
        return lowestCommonAncestor(root.right,p,q);
        else if (root.val>q.val && root.val>p.val){
           return lowestCommonAncestor(root.left,p,q)
        }
    }
};
const lowestCommonAncestor = (root, p, q) => {
    if (p.val < root.val && q.val < root.val) {
        return lowestCommonAncestor(root.left, p, q);
    }
    if (p.val > root.val && q.val > root.val) {
        return lowestCommonAncestor(root.right, p, q);
    }
    return root;
};